var ligerGrid;

$(function() {
			var options = {
				queryKey : queryKey,
				pageSize : 30,
				gridWidth : null,
				gridHeight : 580,
				showIdx : false,
				// init param for groove.query, property querykey is reserved,
				// property method is reserved,
				// init param for groove.view, property id is reserved
				gridRender : function(grid) {
					ligerGrid = grid;
				}
			};
			var gridPanel = new $.grooveQuery(options);

			$("#pageloading").hide();
		});

function defaultFnRender(rowdata, rowindex, value, column) {
	if (column.name == "FC_STATUS") {
		if (value == -1) {
			return "作废";
		} else if (value == 0) {
			return "执行中";
		} else if (value == 1) {
			return "变更";
		} else if (value == 2) {
			return "归档";
		}
	} else if (column.name == "FC_DATE" || column.name == "FC_TIME") {
		return formatDate(value);
	} else if (column.name == "SP") {
		if (rowdata["FC_STATUS"] == 0) {
			return "<a href=\"javascript:void(0);\" title=\"贷款合同信息查阅\" onclick=\"viewContract('"
				+ rowdata["PK_ID"] + "')\">查阅</a>";
		}
	}
	return value;
}

function viewContract(id) {
	var jsonparams = {
		id : id,
		primaryTable : "financialContract"
	}

	var editDialog;

	new $.grooveViewPreII(jsonparams, "viewcreditcontract", {
				formID : "formID",
				mode : "view",
				beforecall : function() {
					$("#target1").css("display", "none");
				},
				aftercall : function() {
					editDialog.hide();

					ligerGrid.reload();
				},
				rendercall : function(selfFunc, validator, validators,
						viewConfig) {
					editDialog = $.ligerDialog.open({
								title : "贷款合同信息预览窗口",
								target : $("#target1"),
								height : 500,
								width : 800,
								buttons : [{
											text : '关闭',
											onclick : function(item, dialog) {
												dialog.hide();
											}
										}],
								isResize : true
							});
				}
			});
}